package com.yuandian.business.monitor.controller;

import com.yuandian.api.business_monitor.po.AlarmParams;
import com.yuandian.api.business_monitor.po.SegmentOverviewParams;
import com.yuandian.bpm.common.core.util.R;
import com.yuandian.business.monitor.service.ISegmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 说明：网端Controller
 *
 * @Author fuxc
 * @Date 2020/12/23
 */
@RestController
@Api(value = "segment", tags = "网端接口")
@RequestMapping("/segment")
public class SegmemtController {

	@Autowired
	private ISegmentService segmentService;


	/**
	 * 查询网端告警类型占比数据
	 *
	 * @param params 参数
	 * @return 通用返回对象
	 */
	@PostMapping("/querySegmentAlarmProportion")
	@ApiOperation(value = "查询网端告警类型占比数据", notes = "查询网端告警类型占比数据")
	public R querySegmentAlarmProportion(AlarmParams params) {
		if (params == null) {
			return R.failed("参数不能为空");
		}
		if (params.getSystemId() == null) {
			return R.failed("系统Id不能为空");
		}
		return R.ok(segmentService.querySegmentAlarmProportion(params));
	}
	/**
	 * 查询网端网元详情
	 *
	 * @param params 参数
	 * @return 通用返回对象
	 */
	@PostMapping("/queryNetworkElementBysegmentId")
	@ApiOperation(value = "查询网端网元详情", notes = "查询网端网元详情")
	public R queryNetworkElementBysegmentId(@RequestBody SegmentOverviewParams params) {
		if (params == null) {
			return R.failed("参数不能为空");
		}
		if (params.getSystemId() == null) {
			return R.failed("系统Id不能为空");
		}
		if (params.getSegmentId() == null) {
			return R.failed("网端Id不能为空");
		}
		return R.ok(segmentService.queryNetworkElementBysegmentId(params));
	}

	/**
	 * 查询网端网元详情
	 *
	 * @param params 参数
	 * @return 通用返回对象
	 */
	@PostMapping("/queryNetworkElementTop")
	@ApiOperation(value = "查询网端网元详情", notes = "查询网端网元详情")
	public R queryNetworkElementTop(@RequestBody SegmentOverviewParams params) {
		if (params == null) {
			return R.failed("参数不能为空");
		}
		if (params.getSystemId() == null) {
			return R.failed("系统Id不能为空");
		}
		if (params.getSegmentId() == null) {
			return R.failed("网端Id不能为空");
		}
		return R.ok(segmentService.queryNetworkElementTop(params));
	}



}
